/* $RCSFile: CustomListDataType.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.Core/UI/DataTypes/CustomListDataType.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:29  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.IO;
using System.ComponentModel;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;

using AddonNice.Diagnostics;
using AddonNice.UI;
using AddonNice.UI.WebControls;
using AddonNice.Configuration;

namespace AddonNice.UI.DataTypes
{

    /// <summary>
	/// CustomListDataType
	/// </summary>
	public class CustomListDataType : ListDataType
	{

		public CustomListDataType(object dataSource, string dataTextField, string dataValueField) : base()
		{
			InnerDataType	=   PropertiesDataType.List;
			InnerDataSource =   dataSource;
			DataValueField	=   dataValueField;
			DataTextField	=   dataTextField;
		}
        
		public override object DataSource
		{
			get
			{
			    if ( DataTypeTraceSwitch.Sw.TraceVerbose )
                    Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]CustomListDataType DataSource InnerDataSource null: {0}", ( InnerDataSource == null )),DataTypeTraceSwitch.Sw.Info);
                if ( InnerDataSource == null )
                    OnNeedData(new EventArgs());
				return InnerDataSource;
			}
			set
			{
			    if ( DataTypeTraceSwitch.Sw.TraceVerbose )
                    Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]CustomListDataType DataSource SET value null: {0}", ( value == null )),DataTypeTraceSwitch.Sw.Info);
				InnerDataSource = value;
			}
		}

        public override string Description
		{
			get
			{
				const string strcust    =   "Custom List";
				return strcust;
			}
		}
	}
}